home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Misc / emu / Wzonka-Lad.lha / Wzonka-Lad / src / test / m_send.s < prev    next >
Text File  |  1998-06-18  |  2KB  |  144 lines

  1.  
  2.         incdir    "binworld:includes/"
  3.  
  4.         include    "exec/memory.i"
  5.         include    "dos/dos.i"
  6.         include    "exec_lib.i"
  7.         include    "dos_lib.i"
  8.         
  9.         include    "devices/inputevent.i"
  10.         include    "devices/serial.i"
  11.         include    "exec/io.i"
  12.  
  13.  
  14.         section    alku,code
  15.  
  16.         move.l    execbase,exec_base
  17.  
  18.         move.l    exec_base,a6
  19.         lea    dos_name,a1
  20.         moveq.l    #39,d0
  21.         jsr    OpenLibrary(a6)
  22.         move.l    d0,dos_base
  23.         beq.w    quit
  24.  
  25.         moveq.l    #64,d0
  26.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  27.         jsr    AllocVec(a6)
  28.         move.l    d0,io_buffer
  29.         beq.w    quit
  30.  
  31.         jsr    CreateMsgPort(a6)
  32.         move.l    d0,input_message_port
  33.         beq.w    quit
  34.  
  35.         move.l    input_message_port,a0
  36.         move.l    #IOEXTSER_SIZE,d0
  37.         jsr    CreateIORequest(a6)
  38.         move.l    d0,io_request
  39.         beq.w    quit
  40.  
  41.         lea    serial_device_name,a0
  42.         move.l    io_request,a1
  43.         bset.b    #5,IO_SERFLAGS(a1)        ;shared access!
  44.         moveq.l    #0,d0
  45.         moveq.l    #0,d1
  46.         jsr    OpenDevice(a6)
  47.         tst.l    d0
  48.         bne.w    quit
  49.  
  50.         move.b    #1,serial_device_status
  51.  
  52.         move.l    io_request,a1
  53.         move.l    #1,IO_LENGTH(a1)
  54.         move.l    io_buffer,IO_DATA(a1)
  55.         move.w    #SDCMD_QUERY,IO_COMMAND(a1)
  56.         jsr    DoIO(a6)
  57.         tst.l    d0
  58.         bne.w    quit
  59.  
  60.         move.l    io_request,a1
  61.         jsr    WaitIO(a6)
  62.  
  63. ;        move.l    io_request,a0
  64. ;        move.w    IO_STATUS(a0),d0
  65. ;        btst    #5,d0
  66. ;        bne.s    quit
  67.  
  68.         move.l    dos_base,a6
  69.         move.l    #50*5,d1
  70.         jsr    Delay(a6)
  71.  
  72.         move.l    exec_base,a6
  73.  
  74.         move.l    io_request,a1
  75.         move.l    #13,IO_LENGTH(a1)
  76.         move.l    #message_data,IO_DATA(a1)
  77.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  78.         jsr    DoIO(a6)
  79.         tst.l    d0
  80.         bne.w    quit
  81.  
  82.         move.l    io_request,a1
  83.         jsr    WaitIO(a6)
  84.  
  85. io_connect_check_abort:
  86. quit:        move.l    exec_base,a6
  87.         move.l    io_request,d0
  88.         beq.s    no_io_request
  89.         move.l    d0,a1
  90.         jsr    _LVOAbortIO(a6)
  91.  
  92.         tst.b    serial_device_status
  93.         beq.s    no_close_device
  94.         move.l    io_request,a1
  95.         jsr    CloseDevice(a6)
  96.  
  97. no_close_device:move.l    io_request,a0
  98.         jsr    DeleteIORequest(a6)
  99.  
  100. no_io_request:    move.l    input_message_port,d0
  101.         beq.s    no_input_message_port
  102.         move.l    d0,a0
  103.         jsr    DeleteMsgPort(a6)
  104.  
  105. no_input_message_port:
  106.         move.l    io_buffer,d0
  107.         beq.s    no_io_buffer
  108.         move.l    d0,a1
  109.         jsr    FreeVec(a6)
  110.  
  111. no_io_buffer:    move.l    dos_base,d0
  112.         beq.s    no_dos_base
  113.         move.l    d0,a1
  114.         jsr    CloseLibrary(a6)
  115.  
  116. no_dos_base:    moveq.l    #0,d0
  117.         rts
  118.  
  119.  
  120.         section    loppu,data
  121.  
  122. exec_base:    dc.l    0
  123. dos_base:    dc.l    0
  124. dos_name:    dc.b    "dos.library",0
  125.         even
  126. serial_device_name:
  127.         dc.b    "8n1.device",0
  128.         even
  129.  
  130. message_data:    dc.b    "GOOD JOB! ^_^",0
  131.         even
  132.  
  133. io_request:    dc.l    0
  134. io_buffer:    dc.l    0
  135.  
  136. input_message_port:
  137.         dc.l    0
  138.  
  139. serial_device_status:
  140.         dc.b    0
  141.         even
  142.  
  143.         END
  144.